﻿<UserControl x:Class="YouTubePlaylist.Views.Desktop"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:Desktop="clr-namespace:Radovici.Ctrls.Desktop;assembly=RadoviciCtrls" 
    xmlns:ContentControls="clr-namespace:Radovici.Ctrls.ContentControls;assembly=RadoviciCtrls" 
    xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" 
    xmlns:Panels="clr-namespace:Radovici.Ctrls.Panels;assembly=RadoviciCtrls" 
    xmlns:Facebook="clr-namespace:Radovici.Ctrls.Facebook;assembly=RadoviciCtrls">
    <UserControl.Resources>
        <ItemsPanelTemplate x:Key="WidgetPanelTemplate">
            <Controls:WrapPanel Orientation="Horizontal"/>
        </ItemsPanelTemplate>
        <DataTemplate x:Key="WidgetDataTemplate">            
            <ContentControls:Dropable IsDragPermanent="True" DropableKey="system">
                <ContentControls:Sizable>
                    <ContentControls:Widget Loaded="OnWidgetLoaded" Closed="OnWidgetClosed"/>
                </ContentControls:Sizable>
            </ContentControls:Dropable>
        </DataTemplate>
        <ItemsPanelTemplate x:Key="MenuItemPanelTemplate">
            <Panels:MacPanel Resistance="0.1" Milliseconds="60"/>
        </ItemsPanelTemplate>
        <DataTemplate x:Key="MenuItemDataTemplate">
            <Controls:Viewbox Stretch="Uniform" Margin="12" >
                <Desktop:MenuItem MouseLeftButtonUp="OnMenuItemClicked">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Text="{Binding Title}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        <Image Grid.Row="1" Source="{Binding Icon}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        <TextBlock Grid.Row="2" Text="{Binding Description}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                    </Grid>
                </Desktop:MenuItem>
            </Controls:Viewbox>
        </DataTemplate>
    </UserControl.Resources>
    <Canvas x:Name="DragableCanvas">
        <Grid x:Name="MainGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="100"/>
                <RowDefinition Height="25"/>
            </Grid.RowDefinitions>
            <Facebook:FacebookConnect ApiKey="5716ce903d9a344ce4f5a1c6491ba3ae" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="8"/>
            <ItemsControl Grid.Row="0" ItemsSource="{Binding Model.WidgetModels}" ItemsPanel="{StaticResource WidgetPanelTemplate}" ItemTemplate="{StaticResource WidgetDataTemplate}"/>
            <ItemsControl Grid.Row="1" ItemsSource="{Binding Model.WidgetTemplates}" ItemsPanel="{StaticResource MenuItemPanelTemplate}" ItemTemplate="{StaticResource MenuItemDataTemplate}"/>
            <Grid Grid.Row="2">
                <ProgressBar IsIndeterminate="{Binding Model.Model.IsCalculating}"/>
                <TextBlock Text="{Binding Model.Model.Status}" VerticalAlignment="Center" Margin="4,0,0,0"/>
            </Grid>
        </Grid>
    </Canvas>
</UserControl>
